using UnityEngine;

public static class TransformEx
{
    public static Transform FindChildEx(this Transform parent, string path)
    {
        if (string.IsNullOrEmpty(path)) return parent;
        var pathArr = path.Split('/');
        var name = pathArr[0];
        if (pathArr.Length == 1)
        {
            return FindChildByName(parent, name);
        }
        return FindChildEx(FindChildByName(parent, name), string.Join("/", pathArr, 1, pathArr.Length - 1));
    }

    public static Transform FindChildByName(this Transform parent, string name)
    {
        foreach (Transform child in parent)
        {
            if (child.name == name) return child;
            var result = FindChildByName(child, name);
            if (result != null) return result;
        }
        return null;
    }
}